package com.lgx.mall.core.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lgx.common.exception.DataException;
import com.lgx.common.web.Pagination;
import com.lgx.mall.core.dao.IScoreCardDao;
import com.lgx.mall.core.entity.ScoreCard;
import com.lgx.mall.core.service.IScoreCardService;

@Service
public class ScoreCardService implements IScoreCardService{
	
	@Autowired
	private IScoreCardDao scoreCardDao;


	public IScoreCardDao getScoreCardDao() {
		return scoreCardDao;
	}

	/**
	 * 创建积分卡
	 */
	@Override
	public ScoreCard createScoreCard(ScoreCard sCard) throws DataException{
		return this.scoreCardDao.createScoreCard(sCard);
	}

	/**
	 * 修改积分卡
	 */
	@Override
	public ScoreCard updateScoreCard(ScoreCard sCard) throws DataException{
		return this.scoreCardDao.updateScoreCard(sCard);
	}

	/**
	 * 删除积分卡
	 */
	@Override
	public void deleteScoreCard(ScoreCard sCard) throws DataException{
		this.scoreCardDao.deleteScoreCard(sCard);
		
	}

	@Override
	public void deleteScoreCard(Long id) throws DataException{
		this.scoreCardDao.deleteScoreCard(id);
		
	}

	/**
	 * 根据id查找积分卡对象
	 */
	@Override
	public ScoreCard findScoreCardById(Long id){
		return this.scoreCardDao.findScoreCardById(id);
	}

	/**
	 * 分页查询
	 */
	@Override
	public Pagination findScoreCardPagination(String card, String scoreStar,
			String scoreEnd, String effectiveTimeStart,
			String effectiveTimeEnd, int pageSize, int pageNum){
		return this.scoreCardDao.findScoreCardPagination(card, scoreStar, scoreEnd, effectiveTimeStart, effectiveTimeEnd, pageSize, pageNum);
	}

	/**
	 * 根据卡号前缀检索同类型id最大的卡号并返回
	 */
	@Override
	public List<ScoreCard> findsScoreCardbyCard(String card) {
		return this.scoreCardDao.findsScoreCardbyCard(card);
	}

	/**
	 * 检查积分卡号
	 */
	@Override
	public List<ScoreCard> checkedScoreCard(String card,String password,String time) {
		return this.scoreCardDao.checkedScoreCard(card,password,time);
	}

}
